Namespace replace
    Module replaceMDL
        Public lst As New ArrayList
        Public Function getchar(ByVal n As Integer)
            If n > 0 And n < 11 Then
                a = n.ToString
            ElseIf n = 11 Then
                a = "a"
            ElseIf n = 12 Then
                a = "b"
            ElseIf n = 13 Then
                a = "c"
            ElseIf n = 14 Then
                a = "d"
            ElseIf n = 15 Then
                a = "e"
            ElseIf n = 16 Then
                a = "f"
            ElseIf n = 17 Then
                a = "g"
            ElseIf n = 18 Then
                a = "h"
            ElseIf n = 19 Then
                a = "i"
            ElseIf n = 20 Then
                a = "j"
            ElseIf n = 21 Then
                a = "k"
            ElseIf n = 22 Then
                a = "l"
            ElseIf n = 23 Then
                a = "m"
            ElseIf n = 24 Then
                a = "n"
            ElseIf n = 25 Then
                a = "o"
            ElseIf n = 26 Then
                a = "p"
            ElseIf n = 27 Then
                a = "q"
            ElseIf n = 28 Then
                a = "r"
            ElseIf n = 29 Then
                a = "s"
            ElseIf n = 30 Then
                a = "t"
            ElseIf n = 31 Then
                a = "u"
            ElseIf n = 32 Then
                a = "v"
            ElseIf n = 33 Then
                a = "w"
            ElseIf n = 34 Then
                a = "x"
            ElseIf n = 35 Then
                a = "y"
            ElseIf n = 36 Then
                a = "z"
                Return a
            End If
        End Function

        Public Function notdigit()  'if it is a ''#''
            'Randomize()
            'Dim generator As New Random
            'Dim r As Integer
            'r = generator.Next(1, 10)
            ''b = getchar(r)
            'n = r

            Randomize(Now.Millisecond)
            n = (Int(Rnd() * 9) + 1)
            If n = 10 Then
                n = 36
            End If
            If n > 0 And n < 10 Then
                a = n.ToString
            ElseIf n = 11 Then
                a = "a"
            ElseIf n = 12 Then
                a = "b"
            ElseIf n = 13 Then
                a = "c"
            ElseIf n = 14 Then
                a = "d"
            ElseIf n = 15 Then
                a = "e"
            ElseIf n = 16 Then
                a = "f"
            ElseIf n = 17 Then
                a = "g"
            ElseIf n = 18 Then
                a = "h"
            ElseIf n = 19 Then
                a = "i"
            ElseIf n = 20 Then
                a = "j"
            ElseIf n = 21 Then
                a = "k"
            ElseIf n = 22 Then
                a = "l"
            ElseIf n = 23 Then
                a = "m"
            ElseIf n = 24 Then
                a = "n"
            ElseIf n = 25 Then
                a = "o"
            ElseIf n = 26 Then
                a = "p"
            ElseIf n = 27 Then
                a = "q"
            ElseIf n = 28 Then
                a = "r"
            ElseIf n = 29 Then
                a = "s"
            ElseIf n = 30 Then
                a = "t"
            ElseIf n = 31 Then
                a = "u"
            ElseIf n = 32 Then
                a = "v"
            ElseIf n = 33 Then
                a = "w"
            ElseIf n = 34 Then
                a = "x"
            ElseIf n = 35 Then
                a = "y"
            ElseIf n = 36 Then
                a = "z"
            End If
            Return a
        End Function

        Public Function wildcard()
            'Randomize()
            'Dim generator As New Random
            'Dim randomValue As Integer
            'randomValue = generator.Next(1, 36)
            'If randomValue = 10 Then
            '    randomValue = 36
            'End If
            'n = randomValue
            Randomize(Now.Millisecond)
            n = (Int(Rnd() * 36) + 1)
            If n = 10 Then
                n = 36
            End If
            If n > 0 And n < 10 Then
                a = n.ToString
            ElseIf n = 11 Then
                a = "a"
            ElseIf n = 12 Then
                a = "b"
            ElseIf n = 13 Then
                a = "c"
            ElseIf n = 14 Then
                a = "d"
            ElseIf n = 15 Then
                a = "e"
            ElseIf n = 16 Then
                a = "f"
            ElseIf n = 17 Then
                a = "g"
            ElseIf n = 18 Then
                a = "h"
            ElseIf n = 19 Then
                a = "i"
            ElseIf n = 20 Then
                a = "j"
            ElseIf n = 21 Then
                a = "k"
            ElseIf n = 22 Then
                a = "l"
            ElseIf n = 23 Then
                a = "m"
            ElseIf n = 24 Then
                a = "n"
            ElseIf n = 25 Then
                a = "o"
            ElseIf n = 26 Then
                a = "p"
            ElseIf n = 27 Then
                a = "q"
            ElseIf n = 28 Then
                a = "r"
            ElseIf n = 29 Then
                a = "s"
            ElseIf n = 30 Then
                a = "t"
            ElseIf n = 31 Then
                a = "u"
            ElseIf n = 32 Then
                a = "v"
            ElseIf n = 33 Then
                a = "w"
            ElseIf n = 34 Then
                a = "x"
            ElseIf n = 35 Then
                a = "y"
            ElseIf n = 36 Then
                a = "z"
            End If
            Return a
        End Function

        Public Function letter()
            'Randomize()
            'Dim generator As New Random
            'Dim randomValue As Integer
            'randomValue = generator.Next(11, 37)
            ''If randomValue = 10 Then
            ''    randomValue = 36
            ''End If
            'n = randomValue

            Randomize(Now.Millisecond)
            n = (Int(Rnd() * 26) + 1)
            n = n + 10
            If n = 10 Then
                n = 36
            End If
            If n > 0 And n < 10 Then
                a = n.ToString
            ElseIf n = 11 Then
                a = "a"
            ElseIf n = 12 Then
                a = "b"
            ElseIf n = 13 Then
                a = "c"
            ElseIf n = 14 Then
                a = "d"
            ElseIf n = 15 Then
                a = "e"
            ElseIf n = 16 Then
                a = "f"
            ElseIf n = 17 Then
                a = "g"
            ElseIf n = 18 Then
                a = "h"
            ElseIf n = 19 Then
                a = "i"
            ElseIf n = 20 Then
                a = "j"
            ElseIf n = 21 Then
                a = "k"
            ElseIf n = 22 Then
                a = "l"
            ElseIf n = 23 Then
                a = "m"
            ElseIf n = 24 Then
                a = "n"
            ElseIf n = 25 Then
                a = "o"
            ElseIf n = 26 Then
                a = "p"
            ElseIf n = 27 Then
                a = "q"
            ElseIf n = 28 Then
                a = "r"
            ElseIf n = 29 Then
                a = "s"
            ElseIf n = 30 Then
                a = "t"
            ElseIf n = 31 Then
                a = "u"
            ElseIf n = 32 Then
                a = "v"
            ElseIf n = 33 Then
                a = "w"
            ElseIf n = 34 Then
                a = "x"
            ElseIf n = 35 Then
                a = "y"
            ElseIf n = 36 Then
                a = "z"
            End If
            Return a
        End Function

        ''' <summary>
        ''' generates #'s to fill the '%' placeholders so that when they
        ''' are added, then divided by 7, the remainder = 0
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub yesdigit()

            Dim count As Integer = 0
            Dim a As String = Form1.txt1.Text
            For i = 1 To Len(a)
                b = Mid(a, i, 1)
                If b = "%" Then
                    count = count + 1
                End If
            Next
            aaa = 1
10:         lst.Clear()
            For i = aaa To count
                lst.Add(Int(Rnd() * 9) + 1)
            Next
            Dim g As Integer = 0
            For s = 1 To lst.Count
                g = g + Val(lst.Item(s - 1))
            Next

            If g / 7 = Int(g / 7) Then
                'MsgBox("right" & g / 7)
                'For i = 1 To lst.Count
                '    MsgBox(lst.Item(i - 1))
                'Next
                'MsgBox(lst.Count)
            Else : GoTo 10

            End If
        End Sub
    End Module
End Namespace
